package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.UserNoticeConfig;
import com.micro.modual.extension.UserNoticeConfigExtension;
import com.micro.modual.mapper.UserNoticeConfigMapper;
import com.micro.modual.model.bo.usernoticeconfig.UserNoticeConfigBO;
import com.micro.modual.service.UserNoticeConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>用户通知配置表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:09
 */
@Service("userNoticeConfigService")
public class UserNoticeConfigServiceImpl extends AbstractBasicsServiceImpl<UserNoticeConfig,Long> implements UserNoticeConfigService {

    @Autowired
    private UserNoticeConfigMapper userNoticeConfigMapper;

    /**
     * <h2>新增用户通知配置表详情</h2>
     * @param userNoticeConfigBO {@link UserNoticeConfigBO} 用户通知配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addUserNoticeConfig(UserNoticeConfigBO userNoticeConfigBO) {
        UserNoticeConfig userNoticeConfig = UserNoticeConfigExtension.converAddUserNoticeConfig(userNoticeConfigBO);
        userNoticeConfigMapper.insertSelective(userNoticeConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改用户通知配置表详情</h2>
     * @param userNoticeConfigBO  {@link UserNoticeConfigBO} 用户通知配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editUserNoticeConfig(UserNoticeConfigBO userNoticeConfigBO) {
        UserNoticeConfig userNoticeConfig = UserNoticeConfigExtension.converEditUserNoticeConfig(userNoticeConfigBO);
        userNoticeConfigMapper.updateByPrimaryKeySelective(userNoticeConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除用户通知配置表信息</h2>
     * @param id  用户通知配置表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteUserNoticeConfig(Long id) {
        userNoticeConfigMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
